<?php
/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Game
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */
?>
<?php 
$game = $this->game;
?>
<div class='game_profile_favorite'>
  
  <?php if ($this->is_favorite): ?>
    <?php echo $this->htmlLink($this->game->getHref(array('action'=>'favorite')), 
      $this->translate('Marked as Favorite'), 
      array('class' => 'game_profile_favorite_remove', 'id'=>'game_profile_favorite_action'))?>
  <?php else: ?>
    <?php echo $this->htmlLink($this->game->getHref(array('action'=>'favorite')), 
      $this->translate('Add to Favorites'), 
      array('class' => 'game_profile_favorite_add', 'id'=>'game_profile_favorite_action'))?>
  <?php endif; ?>
</div>

<script type="text/javascript">

  en4.core.runonce.add(function(){
    
    var anchor = $('game_profile_favorite_action').getParent();

    $('game_profile_favorite_action').removeEvents('click').addEvent('click', function(event){
    	event.stop();
      en4.core.request.send(new Request.HTML({
        url : $('game_profile_favorite_action').get('href'),
        data : {
          format : 'html'
        }
      }), {
        'element' : anchor
      });

    });

  });
</script>

